<template>
<div>
  <HomeHeader class="home" :city="city"></HomeHeader>
  <HomeSwiper :List="swiperList"></HomeSwiper>
  <HomeIcons :List="iconList"></HomeIcons>
  <HomeRecommend :List="recommendList"></HomeRecommend>
  <HomeWeekend :List="weekendList"></HomeWeekend>
</div>
</template>
<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
  name: 'Home',
  components: {
    HomeHeader: HomeHeader,
    HomeSwiper: HomeSwiper,
    HomeIcons: HomeIcons,
    HomeRecommend: HomeRecommend,
    HomeWeekend: HomeWeekend
  },
  data: function () {
    return {
      city: '',
      swiperList: [],
      iconList: [],
      recommendList: [],
      weekendList: []
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('/api/index.json').then(this.getHomeinfosucc)
    },
    getHomeinfosucc (res) {
      console.log(res)
      if (res.data.data.city) {
        this.city = res.data.data.city
      }
      if (res.data.data.swiperList) {
        this.swiperList = res.data.data.swiperList
      }
      if (res.data.data.iconList) {
        this.iconList = res.data.data.iconList
      }
      if (res.data.data.recommendList) {
        this.recommendList = res.data.data.recommendList
      }
      if (res.data.data.weekendList) {
        this.weekendList = res.data.data.weekendList
      }
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>
<style>
</style>
